home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / satellit / pacdoc / elogdisp.c < prev    next >
Text File  |  1991-04-12  |  4KB  |  119 lines

  1. /* SEU log display program for new format eltlog and eltlogxx files. */
  2. /* Use for UO-14 files after 04 April 1991.                          */
  3. /* Use for AO-16 and LO-19 files after March 1991.                   */
  4. /* File formatted for tab stops 3, 5, 7, etc                         */
  5. /* Structure contains NO slack bytes.                                */
  6. /* INTEL lsb-first ordering assumed.                                 */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <time.h>
  11.  
  12. #pragma pack(1)                                                                    /* Just in case.                        */
  13. struct MEMERR {
  14.     long time;                                                                        /* time of correction                */
  15.     unsigned int cluster;                                                    /* cluster of error                    */
  16.     int sector;                                                                        /* sector w/in cluster            */
  17.     int byte;                                                                            /* byte w/in sector                    */
  18.     unsigned long fnumber;                                                /* File in which error was    */
  19.     int severity;                                                                    /* 0 none, 1 corrected,         */
  20.                                                                                                 /* 2 very bad.                            */
  21.                                                                                                 /* 3 seu in program RAM            */
  22.     char pattern;                                                                    /* pattern for type 1                */
  23.     int function;                                                                    /* reason for check                    */
  24. };
  25.  
  26. /* For MEMERR.function            */
  27. #define FUNC_WASH 1                                                            
  28. #define FUNC_READ 2
  29.  
  30.  
  31. /*------------------------------------------------------------------------
  32.     Funct    :        elogdisp
  33.     Date    :
  34.     Action    :    Displays the error log from the PCE.
  35.     ARGS    :
  36.     RETURNS    :
  37.     GLOBALS    :
  38. ------------------------------------------------------------------------*/
  39. main(int argc, char * argv[]){
  40.     struct MEMERR seu;
  41.     FILE *fp;
  42.     char s1[30];
  43.  
  44.     if (argc < 2) {
  45.         printf("Display eltlog file with Format Ver. 2.\n");
  46.         printf("usage: elogdisp <filename>\n");
  47.         exit(-1);
  48.     }
  49.     
  50.     if ( (fp=fopen(argv[1], "rb")) == NULL) {
  51.         printf("File <%s> does not exist.\n", argv[1]);
  52.         exit(-2);
  53.     }
  54.      
  55.     printf("SEU LOG:\n");
  56.     printf("     Time             Cluster Sector  Byte  Patrn Type    File     Function\n");
  57.     printf("-------------------   ------- ------  ----  ----- ----    -------  --------\n");
  58.     while (!feof(fp)){
  59.         if (fread(&seu, sizeof(struct MEMERR), 1, fp)) {
  60.  
  61.                 /* Time, cluster and sector always valid */
  62.                 sprintf(s1, asctime(gmtime(&seu.time)));
  63.                 s1[strlen(s1)-1] = '\0';
  64.                 printf("%20.20s  ", s1);
  65.                 printf("0x%04x  ", seu.cluster);
  66.                 printf("0x%04x  ", seu.sector);
  67.                 /* Byte only valid on correctable errors */
  68.                 if (seu.severity == 1){
  69.                     printf("0x%02x  ", seu.byte);
  70.                     printf("0x%02x  ", seu.pattern & 0xff);
  71.                 }
  72.                 else{
  73.                     printf("----- ");
  74.                     printf("----- ");
  75.                 }
  76.                 switch (seu.severity) {
  77.                     case 1:
  78.                         printf("Fixed   ");
  79.                     break;
  80.  
  81.                     case 2:
  82.                         printf("SEVERE  ");
  83.                     break;
  84.                 }
  85.  
  86.                 /* During WASH cycles, fnumber has 4 meanings */
  87.                 if (seu.function == FUNC_WASH){
  88.                     if (seu.fnumber == 0l)
  89.                         printf("Directry ");
  90.                     else if (seu.fnumber == -1l)
  91.                         printf("in FAT   ");
  92.                     else if (seu.fnumber == -2l)
  93.                         printf("in FREE  ");
  94.                     else
  95.                         printf("%08lx ", seu.fnumber);
  96.                 }
  97.                 /* During READ cycles, fnumber has no meaning */
  98.                 else if (seu.function == FUNC_READ){
  99.                     if (seu.fnumber < 1l)
  100.                         printf("error    ");
  101.                     else
  102.                         printf("unknown  ");
  103.                 }
  104.                 else
  105.                     printf(  "bad func ");
  106.  
  107.                 /* Tell which function it was */
  108.                 if (seu.function == FUNC_WASH)
  109.                     printf("Wash\n");
  110.                 else if (seu.function == FUNC_READ)
  111.                     printf("Read\n");
  112.                 else printf("????\n");
  113.  
  114.         }
  115.     }
  116.  
  117. }
  118.  
  119.